package com.qf.news.controller;


import com.qf.news.entity.NewsInfo;
import com.qf.news.entity.R;
import com.qf.news.entity.SearchInfo;
import com.qf.news.service.NewsInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 新闻信息表(NewsInfo)表控制层 阿斯顿发山东发生的
 *
 * @author makejava
 * @since 2023-07-20 10:11:38
 */
@RestController
@RequestMapping("newsInfo")
@CrossOrigin
public class NewsInfoController {
    /**
     * 服务对象
     */
    @Autowired
    private NewsInfoService newsInfoService;


    @RequestMapping("/insert")
    public R insert(NewsInfo newsInfo){
        newsInfoService.save(newsInfo);
        return R.succ(null);
    }

    /**
     * 新闻列表
     * @return
     */
    @RequestMapping("/list")
    public R list(SearchInfo searchInfo){
        List<NewsInfo> newsInfos = newsInfoService.listBySearch(searchInfo);
        return R.succ(newsInfos);
    }

}

